import {getmsg} from '@/api'
export default{
    namespaced: true,
    state: {
        arr:[],
    },
    mutations: {
        SETARR(state,payload){
            state.arr=payload
        },
        DELARR(state,payload){
            payload.inventory--
        },
        ADDARR(state,payload){
            let ccc = state.arr.find(item=>item.id===payload.id)
            if(ccc){
                ccc.inventory++
            }
        },
        ADDARRS(state,payload){
            let ccc = state.arr.find(item=>item.id===payload.id)
            if(ccc){
                ccc.inventory--
            }

        }
    },
    actions: {
        async GETMSG(context){
            await getmsg()
            .then(body=>body.json())
            .then(res=>{
                console.log(res);
                context.commit('SETARR',res.data)
            })
        }
    },
    getters: {
        
    }
}